home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / System / MCC_SpeedBar / Developer / C / Examples / GCC / applic.cpp next >
C/C++ Source or Header  |  1999-10-13  |  7KB  |  174 lines

  1. #include <exec/types.h>             //  exec
  2. #include <exec/libraries.h>
  3. #include <exec/memory.h>
  4. #include <dos/dos.h>                //  dos
  5. #include <libraries/mui.h>          //  libraries
  6. #include <clib/muimaster_protos.h>  //  clib
  7. #include <clib/alib_protos.h>
  8. #include <proto/exec.h>             //  proto
  9. #include <proto/dos.h>
  10. #include <proto/muimaster.h>
  11.  
  12. #include <string.h>
  13. #include <stdio.h>
  14.  
  15. #include <MUI/SpeedBar_mcc.h>
  16. #include "mybrush.hpp"
  17. #include "applic.hpp"
  18.  
  19. struct Library *MUIMasterBase;
  20. struct Library *IntuitionBase;
  21.  
  22. Object *applic::MakeLabel1( STRPTR str )
  23.     {
  24.     return( MUI_MakeObject( MUIO_Label, str, MUIO_Label_SingleFrame ));
  25.     }
  26.  
  27. Object *applic::MakeCheck( STRPTR str )
  28.     {
  29.     Object *obj = MUI_MakeObject( MUIO_Checkmark, str );
  30.  
  31.     if( obj ) SetAttrs( obj, MUIA_CycleChain, TRUE, TAG_DONE );
  32.  
  33.     return( obj );
  34.     }
  35.  
  36. Object *applic::MakeCycle( STRPTR *array, STRPTR txt )
  37.     {
  38.     Object *obj = MUI_MakeObject( MUIO_Cycle, txt, array );
  39.  
  40.     if( obj ) SetAttrs( obj, MUIA_CycleChain, TRUE, TAG_DONE );
  41.  
  42.     return( obj );
  43.     }
  44.  
  45.  
  46. struct MUIS_SpeedBar_Button buttons[] = {
  47.                                         { 0, "Toggle",    "Toggle mode example",      MUIV_SpeedBar_ButtonFlag_Toggle,    NULL },
  48.                                         { 1, "Immediate", "Immediate mode example",   MUIV_SpeedBar_ButtonFlag_Immediate, NULL },
  49.                                         { MUIV_SpeedBar_Spacer },
  50.                                         { 2, "Quit",      "This will quit the program", 0, NULL },
  51.                                         { 2, "Disabled",  "This does nothing at all",   MUIV_SpeedBar_ButtonFlag_Disabled, NULL },
  52.                                         { MUIV_SpeedBar_End }
  53.                                         };
  54.  
  55.  
  56. applic::applic(void)
  57.     {
  58.     IntuitionBase = (struct Library *) OpenLibrary ( (UBYTE *) "intuition.library", 38);
  59.     if(!( MUIMasterBase = (struct Library *) OpenLibrary( (UBYTE *) "muimaster.library", 19 ))) exit( 20 );
  60.  
  61.     STRPTR Files[] = { "Pic1.iff", "Pic2.iff", "Pic3.iff", "Spacer.iff" };
  62.     for( int i = 0; i < 4; i++ ) Brushes[ i ] = LoadBrush( Files[ i ]);
  63.  
  64.     Modes[0] = "Text + Graphics";
  65.     Modes[1] = "Graphics only";
  66.     Modes[2] = "Text only";
  67.     Modes[3] = NULL;
  68.  
  69.     AppObj = ApplicationObject,
  70.              MUIA_Application_Title,       "SpeedBar Test++",
  71.              MUIA_Application_Version,     "$VER: SpeedBarTest++ 1.0 (22.09.1999)",
  72.              MUIA_Application_Copyright,   "Copyright ©1999 by Diego de Felice",
  73.              MUIA_Application_Author,      "Diego de Felice <d.defelice@ba.nettuno.it>",
  74.              MUIA_Application_Description, "Speed(Bar|Button).mcc test program in C++",
  75.              MUIA_Application_Base,        "SPEEDBARTESTPP",
  76.  
  77.              SubWindow, MainWin = WindowObject,
  78.                         MUIA_Window_ID,    MAKE_ID( 'M', 'A', 'I', 'N' ),
  79.                         MUIA_Window_Title, "SpeedBarTest++ - ©1999 Diego de Felice",
  80.  
  81.                         WindowContents, VGroup,
  82.  
  83.                             Child, HGroup,
  84.  
  85.                                 Child, SpeedBar = SpeedBarObject,
  86.                                     MUIA_Group_Horiz,           TRUE,
  87.                                     MUIA_SpeedBar_Images,       Brushes,
  88.                                     MUIA_SpeedBar_Borderless,   FALSE,
  89.                                     MUIA_SpeedBar_ViewMode,     MUIV_SpeedBar_ViewMode_TextGfx,
  90.                                     MUIA_SpeedBar_RaisingFrame, FALSE,
  91.                                     MUIA_SpeedBar_Buttons,      buttons,
  92.                                     MUIA_SpeedBar_SpacerIndex,  3, // -1,
  93.                                     MUIA_SpeedBar_Spread,       FALSE, //TRUE,
  94.                                 End,
  95.  
  96.                                 Child, HSpace( 0 ),
  97.                             End,
  98.  
  99.                             Child, ColGroup( 2 ),
  100.  
  101.                                 Child, MakeLabel1( "_Borderless" ),
  102.                                 Child, HGroup,
  103.                                     Child, borderless = MakeCheck( "_Borderless" ),
  104.                                     Child, HSpace( 0 ),
  105.                                 End,
  106.  
  107.                                 Child, MakeLabel1( "_Raising frames" ),
  108.                                 Child, HGroup,
  109.                                     Child, raising = MakeCheck( "_Raising frames" ),
  110.                                     Child, HSpace( 0 ),
  111.                                 End,
  112.  
  113.                                 Child, MakeLabel1( "_View Mode" ),
  114.                                 Child, HGroup,
  115.                                     Child, viewmode = MakeCycle( Modes, "_View Mode" ),
  116.                                     Child, HSpace( 0 ),
  117.                                 End,
  118.  
  119.                                 Child, MakeLabel1( "Small _images" ),
  120.                                 Child, HGroup,
  121.                                     Child, small = MakeCheck( "Small _images" ),
  122.                                     Child, HSpace( 0 ),
  123.                                 End,
  124.  
  125.                                 Child, MakeLabel1( "_Sunny" ),
  126.                                 Child, HGroup,
  127.                                     Child, sunny = MakeCheck( "_Sunny" ),
  128.                                     Child, HSpace( 0 ),
  129.                                 End,
  130.                             End,
  131.                         End,
  132.              End,
  133.         End;
  134.  
  135.         if(AppObj)
  136.           {
  137.           DoMethod( MainWin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
  138.  
  139.           DoMethod( buttons[ 0 ].Object, MUIM_Notify, MUIA_Selected, FALSE, SpeedBar, 5, MUIM_SpeedBar_DoOnButton, 1, MUIM_Set, MUIA_Selected, FALSE );
  140.           DoMethod( buttons[ 3 ].Object, MUIM_Notify, MUIA_Pressed,  FALSE, AppObj,   2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
  141.  
  142.           DoMethod( borderless, MUIM_Notify, MUIA_Selected,     MUIV_EveryTime, SpeedBar, 3, MUIM_Set, MUIA_SpeedBar_Borderless,   MUIV_TriggerValue );
  143.           DoMethod( raising,    MUIM_Notify, MUIA_Selected,     MUIV_EveryTime, SpeedBar, 3, MUIM_Set, MUIA_SpeedBar_RaisingFrame, MUIV_TriggerValue );
  144.           DoMethod( viewmode,   MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, SpeedBar, 3, MUIM_Set, MUIA_SpeedBar_ViewMode,     MUIV_TriggerValue );
  145.           DoMethod( small,      MUIM_Notify, MUIA_Selected,     MUIV_EveryTime, SpeedBar, 3, MUIM_Set, MUIA_SpeedBar_SmallImages,  MUIV_TriggerValue );
  146.           DoMethod( sunny,      MUIM_Notify, MUIA_Selected,     MUIV_EveryTime, SpeedBar, 3, MUIM_Set, MUIA_SpeedBar_Sunny,        MUIV_TriggerValue );
  147.  
  148.           SetAttrs( MainWin, MUIA_Window_Open, TRUE, TAG_DONE );
  149.           }
  150.     }
  151.  
  152. applic::~applic(void)
  153.     {
  154.     MUI_DisposeObject( AppObj );
  155.     for( int i = 0; i < 4; i++ ) FreeBrush( Brushes[ i ]);
  156.     CloseLibrary( MUIMasterBase );
  157.     CloseLibrary( IntuitionBase);
  158.     }
  159.  
  160. void applic::inlooppati(void)
  161.     {
  162.     ULONG sigs = 0;
  163.  
  164.     while( DoMethod( AppObj, MUIM_Application_NewInput, &sigs ) != MUIV_Application_ReturnID_Quit )
  165.         {
  166.         if( sigs )
  167.             {
  168.             sigs = Wait( sigs | SIGBREAKF_CTRL_C );
  169.             if( sigs & SIGBREAKF_CTRL_C ) break;
  170.             }
  171.         }
  172.     }
  173.  
  174.